#include "stdafx.h"
#include "ModelNode.h"
#include "Model.h"
#include "Renderer.h"
#include "Material.h"

using namespace mscene;

ModelNode::ModelNode(Model * model)
{
	assert(model != NULL);
	mModel = model;

	mDrawCall.Model = model;

	mWorld = XMMatrixIdentity();

	//char buf[32];
	//LOG(_itoa((int)&mDrawCall - (int)this, buf, 10));
}

void ModelNode::sendToRenderer()
{
	mDrawCall.WorldMatrix = mWorld;

	gRenderer->addModel(ModelDrawCall::Key(mModel->getMaterial()->Shader->ID), &mDrawCall);
}

void ModelNode::setPosition(const XMFLOAT3 & position)
{
	mWorld = XMMatrixTranslation(position.x, position.y, position.z);
}